package cn.edu.scau.cmi.huhaoxian.singleton.pojo;

import cn.edu.scau.cmi.huhaoxian.singleton.exception.InstanceNotFoundException;

public class Chairman {
	
	private String name = "";
	private static boolean isCreated = false;
	
	private static Chairman chairman = null;
	
	private Chairman(String name) {
		isCreated = true;
		this.name = name;
	}
	
	public String getName() {
		return name;
	}

	public static Chairman createChairman(String name) {
		if(!isCreated) {
			chairman = new Chairman(name);
			return chairman;
		}else {
			return chairman;
		}
	}
	
	public static Chairman getInstacne() throws InstanceNotFoundException {
		if(!isCreated) throw new InstanceNotFoundException();
		return chairman;
	}
	
	public static boolean isInstanced() {
		return isCreated;
	}
	
}
